#include <string> 
#include <iostream> 
#include <fstream> 
#include <sstream> 
#include <vector>
#include <dirent.h>

using namespace std; 

//Splits string by delimiter and stores it in vector<string> for now. may move to template type
void split (string line, char delim, vector<string> & data) 
{   
    string tmp;
    stringstream sstr(line);
    while(getline(sstr, tmp, delim))
    {   
        if(tmp[0]=='\t')
        {
            tmp.erase(0,1);
        }
        if(tmp.size()!=0)
        {
            data.push_back(tmp);
        }
    }
}

int main( int argc, char** argv ) 
{ 
    /*string path = string(argv[0]);
    path = path.substr(0, path.rfind('\\'));
    unsigned char isFile = 0x8;
    DIR * Dir;
    struct dirent * DirEntry;
    Dir = opendir(path.c_str());*/

    
    string line, tmp;
    stringstream sstr;
    fstream fileIn, fileOut;
    vector<string> strData;

    /*while(DirEntry=readdir(Dir))
    {
        if(DirEntry->d_type == isFile)
        {
            
        }
    }*/
    
    fileIn.open(argv[1], ios::in);
    
    if(fileIn.is_open())
    {
        while(fileIn.good())
        {
            //So Simple!
            getline(fileIn, line);
            split(line, ' ', strData);
        }
    }
    fileIn.close();
    
    vector<string>::iterator it;
    for ( it=strData.begin() ; it < strData.end(); it++ )
        cout << *it << " ";

    cout<<"\nSize: "<<strData.size()<<endl;
    return 0;
}  

//Noob's Code
/*getline(fileIn, line);
            sstr.str(line);
            while(sstr>>tmp)
            {
                sstr<<tmp;
                strData.push_back(tmp);
            }
            sstr.clear();*/

